package com.zp2.service.impl;

import com.zp2.model.utils.Code;
import com.zp2.service.UtilsService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.stereotype.Service;

@Service
public class UtilsServiceImpl implements UtilsService {
    @Autowired
    private RedisTemplate<String, String> redisTemplate;

    @Override
    public void storeCaptcha(Code code) {
        String username = code.getUsername();
        String phone = code.getPhone();
        String code2 = code.getCode();
        if(null!=username){
            redisTemplate.opsForValue().set(username,code2);
        }else if(null!=phone){
            redisTemplate.opsForValue().set(phone,code2);
        }
    }
}
